package org.grottarossa.ui.core.casemanagement.discussions;


import java.math.BigDecimal;
import java.util.Arrays;

import org.grottarossa.template.drivers.components.tokens.CaseManagementId;

import com.vaadin.data.util.BeanItem;
import com.vaadin.ui.Field;
import com.vaadin.ui.Form;
import com.vaadin.ui.GridLayout;

public class DiscussionForm extends Form {
	/**
	 *
	 */
	private static final long serialVersionUID = 4872151660413447069L;
	private GridLayout topic;

	public DiscussionForm(CaseManagementId id, BeanItem discussionItem, int par) {
		topic = new GridLayout (1, 2);
		setLayout(topic);
		setFormFieldFactory(new DiscussionFormFactory(par));
		setItemDataSource(discussionItem);
		setVisibleItemProperties(Arrays.asList(new String[] {"name", "body"}));
		setSizeUndefined();
	}

	@Override
    protected void attachField(Object propertyId, Field field) {
		if (propertyId.equals("name")) {
        	topic.addComponent(field, 0, 0);
        } else if (propertyId.equals("body")) {
        	topic.addComponent(field, 0, 1);
        }
    }

}
